home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / latex209 / contrib / supertab / supertabular.doc < prev    next >
Text File  |  1994-05-16  |  30KB  |  832 lines

  1. %%% ====================================================================
  2. %%%  @LaTeX-style-file{
  3. %%%     author-1        = "Braams J.L.",
  4. %%%     author-2        = "Jurriens, T.",
  5. %%%     version         = "3.7b",
  6. %%%     date            = "16 May 1994",
  7. %%%     time            = "16:11:07 MET",
  8. %%%     filename        = "supertabular.sty",
  9. %%%     shortfilename   = "supertab.sty"
  10. %%%     address-1       = "PTT Research
  11. %%%                        St. Paulusstraat 4
  12. %%%                        2264 XZ Leidschendam
  13. %%%                        The Netherlands",
  14. %%%     address-2       = "Rijksuniversiteit Groningen
  15. %%%                        P.O. Box 800
  16. %%%                        9700 AV Groningen
  17. %%%                        The Netherlands",
  18. %%%     telephone       = "(70) 3325051",
  19. %%%     FAX             = "(70) 3326477",
  20. %%%     checksum        = "53924 541 2505 23783",
  21. %%%     email           = "J.L.Braams@research.ptt.nl (Internet)",
  22. %%%     codetable       = "ISO/ASCII",
  23. %%%     keywords        = "",
  24. %%%     supported       = "yes",
  25. %%%     abstract        = "A style optioin that implements multi-page
  26. %%%                        tables. The tables have their natural
  27. %%%                        widths on the subsequent pages.",
  28. %%%     docstring       = "The checksum field above contains a CRC-16
  29. %%%                        checksum as the first value, followed by the
  30. %%%                        equivalent of the standard UNIX wc (word
  31. %%%                        count) utility output of lines, words, and
  32. %%%                        characters.  This is produced by Robert
  33. %%%                        Solovay's checksum utility.",
  34. %%%  }
  35. %%% ====================================================================
  36. %
  37. % ===> This file can NOT YET be run through LaTeX with the doc option <==
  38. %
  39. % supertabular sty
  40. % original idea:  Theo Jurriens 1988
  41. %                 jurriens@fwn.rug.nl P.O Box 800, 9700 AV Groningen
  42. %
  43. % revised by:     Johannes Braams
  44. %                 J.L.Braams@research.ptt.nl   PTT Research Leidschendam (NL)
  45. % \def\fileversion{3.7a}
  46. % \def\filename{supertabular sty}
  47. % \def\filedate{1994/05/16}
  48. %
  49. % \changes{v3.7b}{1994/05/16}{Rewrote the page break deciding
  50. %    algorithm again}
  51. % \changes{v3.7b}{1994/05/16}{Started to convert to dtx format}
  52. %
  53. % 05.04.93  - Supertabular didn't work correctly in twocolumn mode.
  54. % V 3.7a      Rewrote the mechanism for establishing the amount of
  55. %             space that supertabular can use. This still needs further
  56. %             thought. The algorithm to compute the places to break
  57. %             the table is still a bit fragile, especially when p{}
  58. %             columns are used.
  59. % 10.07.92  - Still a problem in the combination of supertabular with array.sty
  60. % V 3.6h      I overlooked the fact that array doesn't use \@tabulacr anymore
  61. %             and it behaves differently with respect to \@startparbox.
  62. % 03.07.92  - A problem in the combination of supertabular with array.sty
  63. % V 3.6g      It can be solved by removing the \string from \def\tableformat
  64. %             and passing \tableformat expanded to \tabular.
  65. % 11.02.92  - Bug found by Michael Heissmeier when p{...} is used.
  66. % V 3.6f      A change in LaTeX.tex didn't find its way into supertabular.
  67. % 01.08.91  - Take height of tabletail into account when computing the
  68. % V 3.6e      maximum tableheight; add tolerance on first (partial) page
  69. %             of the supertabular.
  70. % 27.06.91  - Cured bug that made the first part of the table one line
  71. % V 3.6d      shorter than the others. Appeared when supertabular was
  72. %             used in a twocolumn environment.
  73. % 26.06.91  - Made \@process@tablecaption a global macro. Previous caption
  74. % V 3.6c      turned up on a table without one.
  75. % 27.05.91  - Replaced \clearpage with \newpage to make supertabulars work
  76. % V 3.6b      in a twocolumn environment. This also prevents all floats
  77. %             from being printed.
  78. % 15.02.91  - Because of the check for the use of tablefirsthead the
  79. % V 3.6a      combination of an \hline in the head and an \hline as the first
  80. %             thing in the data went wrong. The \futurelet in the definition
  81. %             of \hline found \fi instead of \hline, so no \doublerulesep
  82. %             was added.
  83. %             Also had to modify the way the environments were defined.
  84. %             The blank space (from the CR after the argument of \supertabular)
  85. %             has to be gobbled. This can only be done using a construction
  86. %             like \def\command#1 {...}. So removed the use of \newenvironment
  87. % 04.02.91  - Added the commands \topcaption, \bottomcaption and \tablecaption
  88. % V 3.6       to include a caption within the supertabular environment. The
  89. %             default behaviour is to put the caption before the actual start
  90. %             of the table.
  91. %           - Also added \tablefirsthead and \tablelasttail to let the
  92. %             user specify a different head for the first page of the table
  93. %             and for consecutive pages as well as different tails for first
  94. %             pages and the last one. If these commands are not used, the
  95. %             default behaviour will be to use the value of \tablehead end
  96. %             \tabletail
  97. %           - Removed the need for the \noalign{\global\let\\=\@stabularcr}
  98. %             commands by storing and resetting \@stabularcr
  99. %
  100. % 16.10.90  Added the supertabular* environment that was in an earlier
  101. % V 3.5     version (2.0) by the original author
  102. %           Reintroduced the version numbering
  103. %
  104. % revised by:     Gabriele Kruljac
  105. %                 kruljac@ds0mpi11   Max-Planck-Institute Stuttgart
  106. %
  107. %
  108. % 06.06.89  Correction: now care is taken of probably existing onecolumn
  109. %           head (title or tables ...) in twocolumn sty.
  110. %
  111. % 10.05.89  Correction: the new \\ definition has been added to the
  112. %           begin of each `sub'-tabular
  113. %           Added: algorithm to produce the tabulars in twocolumn style
  114. %
  115. % 06.04.89  Correction: put \global statement in \end{supertabular}
  116. %           into \noalign
  117. %
  118. % 22.02.89  Correction: restore the original meaning of \\ with
  119. %           \end{supertabular}
  120. %
  121. % (Feb 89) The whole algorithm has been changed, so that I can use
  122. %          the most features of a normal tabular:
  123. %          \\  for new line, including  \\[#1]
  124. %          p{...} in the preamble ...
  125. %          Account is taken to \baselinestretch and \arraystretch
  126. %         -I'm not counting the lines because of too much rounding errors
  127. %          but instead I add the (estimated) used space in pt.
  128. %         -The tablehead is taken into this algorithm of proofing, so
  129. %          I really know how much space the head uses.
  130. %         -When no p-arg is given I add a variable \midlineheight to
  131. %          calculate the used space. To calculate \midlineheight I
  132. %          take the \baselineskip, which is active when the supertabular
  133. %          starts (\baselineskip includes the \value of \baselinestretch)
  134. %          and multiply it with \arraystretch.
  135. %         -When a p-arg is given the text will be stored in a box. So
  136. %          I know the height I have to add. Also I reduce the maximum
  137. %          pagesize, so that the last parbox on a page can get up to
  138. %          max 4 lines without producing an overfull vbox.
  139. %         -To do so I had to make some additions to LaTeX's tabular
  140. %          commands. These new commands got a leading `s'.
  141. %
  142. %          Weak points:
  143. %          -When the material of a normal entry (not a p-arg) becomes
  144. %           larger than the estimated \midlineheight, overfull vboxes
  145. %           will be produced at all.
  146. %          -When the last p-arg on a page gets more than 4 lines
  147. %           (probably even more than 3 lines) it will result in an
  148. %           overfull vbox.
  149. %           Also some combinations of \baselinestretch \arraystretch and
  150. %           a large font may lead to one line too much.
  151. %          -if accidentally the last line of the tabular produces
  152. %           a newpage, on the next page the tabletail will be written
  153. %           immediately after the tablehead. Depending on the contents
  154. %           this may result in an error message regarding misplaced
  155. %           \noalign.
  156. %
  157. %           A quick but not very elegant solution: shrink \maxsize by
  158. %           \noalign{\global\maxsize=...pt} after the first \\ of the
  159. %           supertabular.
  160. %
  161. %------------------------------------------------------------------------------
  162. % \begin{macro}{\topcaption}
  163. % \begin{macro}{\bottomcaption}
  164. %    The user-commands |\topcaption| and |\bottomcaption| set the
  165. %    boolean  |@topcaption| to determine where to put the
  166. %    tablecaption. The default  is to put the caption on the top of
  167. %    the table 
  168. %    \begin{macrocode}
  169. %    \begin{macrocode}
  170. \newif\if@topcaption \@topcaptiontrue
  171. \def\topcaption{\@topcaptiontrue\tablecaption}
  172. \def\bottomcaption{\@topcaptionfalse\tablecaption}
  173. %    \end{macrocode}
  174. %    \end{macrocode}
  175. % \end{macro}
  176. % \end{macro}
  177. %
  178. % \begin{macro}{\tablecaption}
  179. %    This command has to function exactly like |\caption| does except
  180. %    it has to store its argument (and the optional argument) for
  181. %    later processing \emph{within} the supertabular environment. 
  182. %
  183. %    \begin{macrocode}
  184. \long\def\tablecaption{%
  185.   \refstepcounter{table} \@dblarg{\@xtablecaption}}
  186. \long\def\@xtablecaption[#1]#2{%
  187.   \long\gdef\@process@tablecaption{\@stcaption{table}[#1]{#2}}}
  188. \global\let\@process@tablecaption\relax
  189. %    \end{macrocode}
  190. % \end{macro}
  191. %
  192. % This is a redefinition of LaTeX's \@caption, \@makecaption is
  193. % called within a group so as not to return to \normalsize globally.
  194. % also a fix is made for the `feature' of the \@makecaption of article.sty and
  195. % friends that a caption ALWAYS gets a \vskip 10pt at the top and NONE at the
  196. % bottom. If a user wants to precede his table with a caption this results
  197. % in a collision.
  198. %
  199. %    \begin{macrocode}
  200. \long\def\@stcaption#1[#2]#3{\par%
  201.   \addcontentsline{\csname ext@#1\endcsname}{#1}%
  202.                   {\protect\numberline{%
  203.                       \csname the#1\endcsname}{\ignorespaces #2}}
  204.   \begingroup
  205.     \@parboxrestore
  206.     \normalsize
  207.     \if@topcaption \vskip -10pt \fi
  208.     \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  209.     \if@topcaption \vskip 10pt \fi
  210.   \endgroup}
  211. %    \end{macrocode}
  212. %
  213. %    |\tablehead| activates the new tabular |\cr| commands.
  214. %    \begin{macrocode}
  215. \newcommand\tablehead[1]{\gdef\@tablehead{#1}}
  216. \tablehead{}
  217. \newcommand\tablefirsthead[1]{\gdef\@table@first@head{#1}}
  218. %    \end{macrocode}
  219. %
  220. %
  221. %    If the user uses an extra amount of tabular-data (like
  222. %    \|multicolumn|) in |\tabletail| \TeX\ starts looping because of
  223. %    the definition of |\nextline|. So make |\\| act like just a |\cr|
  224. %    inside this tail to prevent the loop.  Save and restore the value
  225. %    of |\\|
  226. %
  227. %    \begin{macrocode}
  228. \newcommand\tabletail[1]{%
  229.   \gdef\@tabletail{%
  230.     \noalign{%
  231.       \global\let\@savcr=\\
  232.       \global\let\\=\cr}%
  233.     #1%
  234.     \noalign{\global\let\\=\@savcr}}}
  235. \tabletail{}
  236. \newcommand\tablelasttail[1]{\gdef\@table@last@tail{#1}}
  237. %    \end{macrocode}
  238. %
  239. %  \begin{macro}{\sttraceon}
  240. % \changes{v3.7b}{1994/05/16}{Added macro}
  241. %  \begin{macro}{\sttraceoff}
  242. % \changes{v3.7b}{1994/05/16}{Added macro}
  243. %    There now is a possiblity to follow the decisions supertabular
  244. %    makes about breaking the tabular. This has to be enabled when
  245. %    converting this file with \texttt{docstrip} to a \texttt{.sty}
  246. %    file. 
  247. %    \begin{macrocode}
  248. %<tracing>\newif\if@st@trace
  249. %<tracing>\newcommand\sttraceon{\@st@tracetrue}
  250. %<tracing>\newcommand\sttraceoff{\@st@tracefalse}
  251. %<tracing>\newif\if@st@trace
  252. %    \end{macrocode}
  253. %    The default is to turn tracing off
  254. %    \begin{macrocode}
  255. %<tracing>\sttraceoff
  256. %    \end{macrocode}
  257. %  \end{macro}
  258. %  \end{macro}
  259. %
  260. %  \begin{macro}{\@sttrace}
  261. %    A macro that gets the trace message as its argument
  262. %    \begin{macrocode}
  263. %<tracing>\newcommand\@sttrace[1]{\if@st@trace\typeout{ST trace: #1}\fi}
  264. %    \end{macrocode}
  265. %  \end{macro}
  266. %
  267. %  \begin{macro}{\page@left}
  268. % \changes{v3.7b}{1994/05/16}{Renamed from \cmd\maxsize}
  269. %    This register holds the estimate of the amount of space left over
  270. %    on the current page. This is used in the decision when to start a
  271. %    new page.
  272. %    \begin{macrocode}
  273. \newdimen\page@left
  274. %    \end{macrocode}
  275. %  \end{macro}
  276. %
  277. %    \begin{macrocode}
  278. \newdimen\actsize            % actual pagesize
  279. \newdimen\@tailht            % height of table tail (if any)
  280. \newdimen\parboxheight       % height plus depth of a parbox-argument
  281. \newdimen\addspace           % stores the value of \\[#1]
  282. \newdimen\midlineheight      % estimated size of a normal line
  283. \newdimen\pargcorrection     % to set page height tolerance if p-arg
  284. \newdimen\computedimens      % computation variable
  285. \newbox\tabparbox
  286. %    \end{macrocode}
  287. %
  288. %  \begin{macro}{\@stabularcr}
  289. %  \begin{macro}{\@sxtabularcr}
  290. %    These are redefinitions of |\@tabularcr| and |\@xtabularcr|. This
  291. %    is needed to include |\nextline| in the definition of
  292. %    |\@xtabularcr|. 
  293. %
  294. %    All redefined macros have names that are similar to the original
  295. %    names, except with a leading 's'
  296. %    \begin{macrocode}
  297. \def\@stabularcr{{\ifnum0=`}\fi\@ifstar{\@sxtabularcr}{\@sxtabularcr}}
  298. \def\@sxtabularcr{%
  299.   \@ifnextchar[{\@sargtabularcr}{\ifnum0=`{\fi}\cr\nextline}}
  300. %    \end{macrocode}
  301. %  \end{macro}
  302. %  \end{macro}
  303. %
  304. %    \begin{macrocode}
  305. \def\@sargtabularcr[#1]{%
  306.   \ifnum0=`{\fi}%
  307.   \ifdim #1>\z@
  308.     \unskip\@sxargarraycr{#1}
  309.   \else 
  310.     \@syargarraycr{#1}%
  311.   \fi}
  312. %    \end{macrocode}
  313. %
  314. %    In this case we need to copy the value of the optional argument
  315. %    of |\\| in our private register |\addspace|.
  316. %    \begin{macrocode}
  317. \def\@sxargarraycr#1{%
  318.   \@tempdima #1\advance\@tempdima \dp \@arstrutbox
  319.   \vrule \@height\z@ \@depth\@tempdima \@width\z@ \cr
  320.   \noalign{\global\addspace=#1}\nextline}
  321. %    \end{macrocode}
  322. %
  323. %    Here we need to insert |\nextline|
  324. %    \begin{macrocode}
  325. \def\@syargarraycr#1{\cr\noalign{\vskip #1\global\addspace=#1}\nextline}
  326. %    \end{macrocode}
  327. %
  328. %    The macros that deal with parbox columns need to be redefined,
  329. %    because we need to know the size of the parbox. Also the maximum
  330. %    size of the tabular on this page is shrunk somewhat.
  331. %    \begin{macrocode}
  332. \def\@sstartpbox#1{%
  333.   \global\advance\page@left by -\pargcorrection
  334.   \global\pargcorrection=0pt
  335. %    \end{macrocode}
  336. %    To achieve our goal we need to save the text in box.
  337. %    \begin{macrocode}
  338.   \setbox\tabparbox\vtop\bgroup\hsize#1\@arrayparboxrestore}
  339. %    \end{macrocode}
  340. %
  341. %    \begin{macrocode}
  342. \def\@sastartpbox#1{%
  343.   \bgroup\hsize#1%
  344.   \global\advance\page@left by -\pargcorrection
  345.   \global\pargcorrection=0pt
  346.   \setbox\tabparbox\vtop\bgroup\hsize#1\@arrayparboxrestore}
  347. %    \end{macrocode}
  348. %
  349. % 11/03/92 JB: The following change didn't find its way into the
  350. %              \@sendpbox command. This caused a difference in linespacing
  351. %              between a supertabular and a normal tabular.
  352. % \def\@endpbox{\unskip\strut\par\egroup\hfil}
  353. % % 14 Jan 89: Def of \@endpbox changed from
  354. % %    \def\@endpbox{\par\vskip\dp\@arstrutbox\egroup\hfil}
  355. % % so vertical spacing works out right if the last line of a `p' entry
  356. % % has a descender.
  357. %    \begin{macrocode}
  358. \def\@sendpbox{%
  359.   \unskip\strut\par\egroup
  360.   \computedimens=\ht\tabparbox
  361.   \advance\computedimens by \dp\tabparbox
  362.   \ifnum\parboxheight<\computedimens
  363.     \global\parboxheight=\computedimens
  364.   \fi
  365.   \computedimens=\z@
  366.   \box\tabparbox\hfil}
  367. \def\@saendpbox{%
  368.   \unskip\strut\par\egroup
  369.   \computedimens=\ht\tabparbox
  370.   \advance\computedimens by \dp\tabparbox
  371.   \ifnum\parboxheight<\computedimens
  372.     \global\parboxheight=\computedimens
  373.   \fi
  374.   \computedimens=\z@
  375.   \unvbox\tabparbox\egroup}
  376. %    \end{macrocode}
  377. %
  378. %         %%%%  Here start really new supertabular commands   %%%%
  379. %
  380. % \begin{macro}{\calmidlineheight}
  381. %    Estimates the height of normal line taking |\arraystretch| into
  382. %    account.
  383. %    \begin{macrocode}
  384. \def\calmidlineheight{%
  385.   \midlineheight=\arraystretch \baslineskp
  386.   \global\advance\midlineheight by 1\p@
  387. %<tracing>  \@sttrace{Average line height:\the\midlineheight}%
  388.   \global\pargcorrection=4\midlineheight
  389. %<tracing>  \@sttrace{Correction for p columns: \the\pargcorrection}%
  390.   }
  391. %    \end{macrocode}
  392. % \end{macro}
  393. %
  394. % \begin{macro}{\@calfirstpageht}
  395. % \changes{v3.7a}{1993/04/05}{Renamed from \cmd\calpage}
  396. %    Estimates the space left on the current page and decides whether
  397. %    the tabular can be started on this page or on a new page.
  398. %    \begin{macrocode}
  399. \def\@calfirstpageht{%
  400. %<tracing>  \@sttrace{Calculating height of tabular on first page}
  401. %    \end{macrocode}
  402. %    The \TeX\ register |\pagetotal| contains the height of the page
  403. %    sofar, the \LaTeX\ register |\@colroom| contains the height of
  404. %    the column.
  405. %    \begin{macrocode}
  406.   \global\actsize\pagetotal
  407.   \global\page@left\@colroom
  408. %<tracing>  \@sttrace{pagetotal = \the\pagetotal; 
  409. %<tracing>            page@left = \the\page@left}%
  410. %    \end{macrocode}
  411. %    When we are in twocolumn mode \TeX\ may still be collecting
  412. %    material for the first column although there seems to be no space
  413. %    left. In this case we have to check against two times |\page@left|.
  414. %    \begin{macrocode}
  415.   \if@twocolumn
  416. %<tracing>    \@sttrace{two column mode}%
  417.     \if@firstcolumn
  418. %<tracing>     \@sttrace{First column}%
  419.       \ifnum\actsize > \page@left 
  420.         \global\maxsize=2\page@left
  421.         \ifnum\actsize > \page@left
  422.           \newpage\@calnextpageht
  423. %<tracing>          \@sttrace{starting new page}%
  424.         \else
  425. %    \end{macrocode}
  426. %    In this case we're in the second column, so we have to compensate
  427. %    for the material in the first column.
  428. %    \begin{macrocode}
  429. %<tracing>     \@sttrace{Second column}%
  430.           \global\advance\page@left -\actsize
  431.           \global\advance\page@left -\@colroom
  432.         \fi
  433.       \fi
  434.     \fi
  435.   \else
  436. %    \end{macrocode}
  437. %    In one column mode there is a simple decision.
  438. %    \begin{macrocode}
  439. %<tracing>    \@sttrace{one column mode}%
  440.     \ifnum\actsize > \page@left
  441. %<tracing>      \@sttrace{starting new page}%
  442.       \newpage\@calnextpageht
  443. %    \end{macrocode}
  444. %    When we are not starting a new page subtract the size of the
  445. %    material already on it from the available space.
  446. %    \begin{macrocode}
  447.     \else
  448.       \global\advance\page@left by -\actsize
  449.       \global\actsize\z@
  450.     \fi
  451.   \fi
  452. %    \end{macrocode}
  453. %    To decide when to start a new page, we need to know the vertical
  454. %    size of the tail of the table.
  455. %    \begin{macrocode}
  456.   \ifx\empty\@tabletail
  457.     \@tailht=\z@
  458.   \else
  459.     \setbox\@tempboxa=\vbox{\@arrayparboxrestore%
  460.       \expandafter\tabular\expandafter{\tableformat}
  461.         \@tabletail\endtabular}
  462.     \@tailht=\ht\@tempboxa\advance\@tailht\dp\@tempboxa
  463.   \fi
  464. %    \end{macrocode}
  465. %    We add the average height of a line to this because when we
  466. %    decide to continue the tabular we need to have enough space left
  467. %    for one line an the tail.
  468. %    \begin{macrocode}
  469.   \advance\@tailht by \midlineheight
  470. %<tracing>  \@sttrace{Height of tail: \the\@tailht}
  471. %<tracing>  \@sttrace{Maximum height of tabular: \the\page@left}
  472. }
  473.                              % Here is the definition of supertabular
  474. %    \end{macrocode}
  475. % \end{macro}
  476. %
  477. % \begin{macro}{\@calnextpageht}
  478. % \changes{v3.7a}{1993/04/05}{Macro added}
  479. %    This calculates the maximum height of the tabular on all
  480. %    subsequent pages of the supertabular environment. The correction
  481. %    for parbox columns is somewhat smaller then on the first page of
  482. %    the environment
  483. %    \begin{macrocode}
  484. \def\@calnextpageht{%
  485. %<tracing>  \@sttrace{Calculating height of tabular on next page}
  486.   \global\page@left\@colroom
  487.   \global\pargcorrection=2\midlineheight
  488. %<tracing>  \@sttrace{Correction for p columns: \the\pargcorrection}%
  489.   \global\actsize=\z@
  490. %<tracing>  \@sttrace{Maximum height of tabular: \the\page@left}
  491.   }
  492. %    \end{macrocode}
  493. % \end{macro}
  494. %
  495. % \begin{macro}{\supertabular}
  496. %    We start by saving the preamble of the tabular in a macro.
  497. %    \begin{macrocode}
  498. \def\supertabular#1 {%
  499.   \def\tableformat{#1}
  500. %<tracing>  \@sttrace{Starting a new supertabular}
  501. %    \end{macrocode}
  502. %    Then remember that this is not a \textsf{supertabular*}
  503. %    environment.
  504. %    \begin{macrocode}
  505.   \global\starfalse
  506. %    \end{macrocode}
  507. %    If the caption should come at the top we insert it here.
  508. %    \begin{macrocode}
  509.   \if@topcaption \@process@tablecaption \fi
  510. %    \end{macrocode}
  511. %    Save the original definition of |\\|.
  512. %    \begin{macrocode}
  513.   \global\let\@oldcr=\\
  514. %    \end{macrocode}
  515. %    Save the current value of |\baselineskip|, as we need it in the
  516. %    calculation of the average height of a line. 
  517. %    \begin{macrocode}
  518.   \def\baslineskp{\baselineskip}%
  519.   \calmidlineheight
  520.   \@calfirstpageht
  521. %    \end{macrocode}
  522. %    We have to check whether \texttt{array.sty} was loaded, because
  523. %    some of the internal macros have different names.
  524. %    \begin{macrocode}
  525.   \ifx\undefined\@classix
  526. %    \end{macrocode}
  527. %    Save old |\@tabularcr| and insert the definition of
  528. %    |\@stabularcr|. 
  529. %    \begin{macrocode}
  530.       \let\@@tabularcr\@tabularcr
  531.       \let\@tabularcr\@stabularcr
  532. %    \end{macrocode}
  533. %    Activate the new parbox algorithm.
  534. %    \begin{macrocode}
  535.       \let\@@startpbox=\@sstartpbox
  536.       \let\@@endpbox=\@sendpbox
  537.   \else
  538. %    \end{macrocode}
  539. %    When \texttt{array.sty} was loaded things are a bit different.
  540. %    \begin{macrocode}
  541.       \let\@@tabularcr\@arraycr
  542.       \let\@arraycr\@stabularcr
  543.       \let\org@startpbox=\@startpbox
  544.       \let\org@endpbox=\@endpbox
  545.       \let\@startpbox=\@sastartpbox
  546.       \let\@endpbox=\@saendpbox
  547.   \fi
  548. %    \end{macrocode}
  549. %
  550. %    Moved the check for the use of \tablefirsthead to befor the start of
  551. %    the tabular environment in order to make the \futurelet inside \hline
  552. %    do its work correctly (15.02.91)
  553. %
  554. %    Check if the head of the table should be different for the first
  555. %    and subsequent pages.
  556. %    \begin{macrocode}
  557.     \ifx\@table@first@head\undefined
  558.         \let\@@tablehead=\@tablehead
  559.     \else
  560.         \let\@@tablehead=\@table@first@head
  561.     \fi
  562. %    \end{macrocode}
  563. %    Finally start a normal \textsf{tabular} environment.
  564. %    \begin{macrocode}
  565.     \expandafter\tabular\expandafter{\tableformat}
  566.     \@@tablehead}
  567. %    \end{macrocode}
  568. % \end{macro}
  569. %
  570. % \begin{macro}{\endsupertabular}
  571. %    This closes the environment.
  572. %    \begin{macrocode}
  573. \def\endsupertabular{%
  574.   \ifx\@table@last@tail\undefined
  575.     \@tabletail
  576.   \else
  577.     \@table@last@tail
  578.   \fi
  579.   \endtabular
  580. %    \end{macrocode}
  581. %    Restore the original definition of |\@tabularcr|
  582. %    \begin{macrocode}
  583.   \ifx\undefined\@classix
  584.     \let\@tabularcr\@@tabularcr
  585.   \else
  586.     \let\@arraycr\@@tabularcr
  587.     \let\@startpbox=\org@startpbox
  588.     \let\@endpbox=\org@endpbox
  589.   \fi
  590. %    \end{macrocode}
  591. %    Check if we have to insert a caption and restore to default
  592. %    behaviour of putting captions at the top.
  593. %    \begin{macrocode}
  594.   \if@topcaption
  595.   \else
  596.     \@process@tablecaption
  597.     \@topcaptiontrue
  598.   \fi
  599. %    \end{macrocode}
  600. %
  601. %    Restore the meaning of |\\| to the one it had before the start
  602. %    of this environment. Also re-initialize some control-sequences
  603. %
  604. %    \begin{macrocode}
  605.   \global\let\\=\@oldcr
  606.   \let\@table@first@head\undefined
  607.   \let\@table@last@tail\undefined
  608.   \global\let\@process@tablecaption\relax
  609. %<tracing>  \@sttrace{Ended a supertabular}
  610.   }
  611. %    \end{macrocode}
  612. % \end{macro}
  613. %
  614. %  \begin{macro}{\ifstar}
  615. %    This switch is used in the internal macros to remember which
  616. %    kind of environment was started.
  617. %    \begin{macrocode}
  618. \newif\ifstar
  619. %    \end{macrocode}
  620. %  \end{macro}
  621. %
  622. %  \begin{macro}{\tabularwidth}
  623. %    For the \textsf{supertabular*} environment it is necessary to
  624. %    store the intended width of the tabular.
  625. %    \begin{macrocode}
  626. \newdimen\tabularwidth
  627. %    \end{macrocode}
  628. %  \end{macro}
  629. %
  630. % \begin{macro}{\supertabular*}
  631. %    We start by saving the intended width and the preamble of the
  632. %    \textsf{tabular*}.
  633. %    \begin{macrocode}
  634. \@namedef{supertabular*}#1#2 {%
  635. %<tracing>  \@sttrace{Starting a new supertabular*}
  636.   \def\tableformat{#2}
  637.   \tabularwidth=#1
  638.   \global\startrue
  639. %    \end{macrocode}
  640. %    If the caption should come at the top we insert it here.
  641. %    \begin{macrocode}
  642.     \if@topcaption\@process@tablecaption\fi
  643. %    \end{macrocode}
  644. %    Save the original definition of |\\|.
  645. %    \begin{macrocode}
  646.   \global\let\@oldcr=\\
  647. %    \end{macrocode}
  648. %    Save the current value of |\baselineskip|, as we need it in the
  649. %    calculation of the average height of a line. 
  650. %    \begin{macrocode}
  651.     \def\baslineskp{\baselineskip}%
  652.     \calmidlineheight
  653.     \@calfirstpageht
  654. %    \end{macrocode}
  655. %    We have to check whether \texttt{array.sty} was loaded, because
  656. %    some of the internal macros have different names.
  657. %    \begin{macrocode}
  658.     \ifx\undefined\@classix
  659. %    \end{macrocode}
  660. %    Save old |\@tabularcr| and insert the definition of
  661. %    |\@stabularcr|. 
  662. %    \begin{macrocode}
  663.       \let\@@tabularcr\@tabularcr
  664.       \let\@tabularcr\@stabularcr
  665. %    \end{macrocode}
  666. %    Activate the new parbox algorithm
  667. %    \begin{macrocode}
  668.       \let\@@startpbox=\@sstartpbox
  669.       \let\@@endpbox=\@sendpbox
  670.     \else
  671. %    \end{macrocode}
  672. %    When \texttt{array.sty} was loaded things are a bit different.
  673. %    \begin{macrocode}
  674.       \let\@@tabularcr\@arraycr
  675.       \let\@arraycr\@stabularcr
  676.       \let\org@startpbox=\@startpbox
  677.       \let\org@endpbox=\@endpbox
  678.       \let\@startpbox=\@sastartpbox
  679.       \let\@endpbox=\@saendpbox
  680.     \fi
  681. %    \end{macrocode}
  682. %
  683. %    Check if the head of the table should be different for the first
  684. %    and subsequent pages.
  685. %    \begin{macrocode}
  686.     \ifx\@table@first@head\undefined
  687.         \let\@@tablehead\@tablehead
  688.     \else
  689.         \let\@@tablehead\@table@first@head
  690.     \fi
  691. %    \end{macrocode}
  692. %    Finally start a normal \textsf{tabular*} environment.
  693. %    \begin{macrocode}
  694.     \expandafter\csname tabular*\expandafter\endcsname
  695.     \expandafter{\expandafter\tabularwidth\expandafter}%
  696.     \expandafter{\tableformat}%
  697.     \@@tablehead}%
  698. %    \end{macrocode}
  699. % \end{macro}
  700. %
  701. % \begin{macro}{\endsupertabular*}
  702. %    This closes the environment.
  703. %    \begin{macrocode}
  704. \@namedef{endsupertabular*}{%
  705.   \ifx\@table@last@tail\undefined
  706.     \@tabletail
  707.   \else
  708.     \@table@last@tail
  709.   \fi
  710.   \csname endtabular*\endcsname
  711. %    \end{macrocode}
  712. %    Restore the old definition of |\@tabularcr|.
  713. %    \begin{macrocode}
  714.   \ifx\undefined\@classix
  715.     \let\@tabularcr\@@tabularcr
  716.   \else
  717.     \let\@arraycr\@@tabularcr
  718.     \let\@startpbox=\org@startpbox
  719.     \let\@endpbox=\org@endpbox
  720.   \fi
  721. %    \end{macrocode}
  722. %    Check if we have to insert a caption and restore to default
  723. %    behaviour of putting captions at the top.
  724. %    \begin{macrocode}
  725.   \if@topcaption
  726.   \else
  727.     \@process@tablecaption
  728.     \@topcaptiontrue
  729.   \fi
  730. %    \end{macrocode}
  731. %
  732. %    Restore the meaning of |\\| to the one it had before the start
  733. %    of this environment. Also re-initialize some control-sequences
  734. %
  735. %    \begin{macrocode}
  736.   \global\let\\=\@oldcr
  737.   \let\@table@first@head\undefined
  738.   \let\@table@last@tail\undefined
  739.   \global\let\@process@tablecaption\relax
  740. %<tracing>  \@sttrace{Ended a supertabular*}
  741.     }
  742. %    \end{macrocode}
  743. % \end{macro}
  744. %
  745. % \begin{macro}{\nextline}
  746. %    This macro is called by each |\\| inside the tabular environment.
  747. %    It updates the estimate of the amount of space left on the
  748. %    current page and starts a new page if necessary.
  749. %    \begin{macrocode}
  750. \def\nextline{%
  751.   \noalign{%
  752.     \ifnum\parboxheight<\midlineheight
  753. %    \end{macrocode}
  754. %    If there is a non-empty line, but an empty parbox, then
  755. %    |\parboxheight| might be non-zero, but too small thereby breaking
  756. %    the algorithm. Therefore we estimate the height of the line to be
  757. %    |\midlineheight| in this case.
  758. %    \begin{macrocode}
  759.       \global\advance\page@left -\midlineheight
  760. %    \end{macrocode}
  761. %    |\addspace| is the value of the optional argument of |\\|.
  762. %    \begin{macrocode}
  763.       \global\advance\page@left -\addspace
  764.     \else
  765. %    \end{macrocode}
  766. %    When the parbox was not empty we take into account its height
  767. %    (plus a bit extra).
  768. %    \begin{macrocode}
  769. %<tracing>     \@sttrace{Added par box with height \the\parboxheight}%
  770.       \global\advance\page@left -\parboxheight
  771.       \global\advance\page@left -0.1\parboxheight
  772.       \global\parboxheight\z@
  773.     \fi
  774.     \global\addspace=\z@
  775. %<tracing>    \@sttrace{Space left for tabular: \the\page@left}
  776.   }
  777. %    \end{macrocode}
  778. %    When there is not enough space left we start a new page.
  779. %    \begin{macrocode}
  780.   \ifnum\page@left<\@tailht
  781.     \st@newpage
  782.   \else
  783. %    \end{macrocode}
  784. %    
  785. %    This line is necessary because the tablehead has to be inserted
  786. %    *after* the |\if\else\fi|-clause. For this purpose |\st@next| is
  787. %    used. In the middle of tableprocessing it shoud be an *empty*
  788. %    macro (*not* |\relax|).  (15.2.91)
  789. %    \begin{macrocode}
  790.     \noalign{\global\let\st@next\@empty}%
  791.   \fi\st@next}
  792. %    \end{macrocode}
  793. % \end{macro}
  794. %
  795. % \begin{macro}{\st@newpage}
  796. % \changes{v3.7b}{1994/05/16}{Added macro, split off from
  797. %    \cmd\nextline}
  798. %    This macro performs the actions necessary to start a new page.
  799. %    \begin{macrocode}
  800. \def\st@newpage{%
  801. %<tracing>  \noalign{\@sttrace{Starting new page, writing tail}}
  802. %    \end{macrocode}
  803. %    Output |\tabletail|, close the tabular environment, output all
  804. %    material and start a fresh new page.
  805. %    \begin{macrocode}
  806.   \@tabletail
  807.   \ifstar
  808.     \csname endtabular*\endcsname
  809.   \else
  810.     \endtabular
  811.   \fi
  812. %  \if@twocolumn
  813. %    \if@firstcolumn
  814. %      \newpage\@calnextpageht
  815. %      \global\actsize=\z@
  816. %    \else
  817. %      \newpage\@calnextpageht
  818. %    \fi
  819. %  \else
  820.     \newpage\@calnextpageht
  821. %  \fi
  822.   \let\st@next\@tablehead
  823. %<tracing>  \@sttrace{writing head}
  824.   \ifstar
  825.     \expandafter\csname tabular*\expandafter\endcsname
  826.     \expandafter{\expandafter\tabularwidth\expandafter}%
  827.     \expandafter{\tableformat}%
  828.   \else
  829.     \expandafter\tabular\expandafter{\tableformat}%
  830.   \fi}
  831. %    \end{macrocode}
  832.